package com.gxar.marketdelivery.domain.aviator.enums;

import com.gxar.marketdelivery.shared.meta.enums.IEnumItem;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @author nice
 * @version 1.0
 * @created 2023/7/23.
 */
public enum WeekDay implements IEnumItem<Integer, String> {
    MONDAY(1, "周一"),
    TUESDAY(2, "周二"),
    WEDNESDAY(3, "周三"),
    THURSDAY(4, "周四"),
    FRIDAY(5, "周五"),
    SATURDAY(6, "周六"),
    SUNDAY(7, "周日");

    private Integer code;
    private String message;

    WeekDay(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private static Map<Integer, WeekDay> ENUM_MAP = new HashMap<>();
    private static Map<Integer, String> CODE_MAP = new HashMap<>();

    static {
        for (WeekDay status : values()) {
            ENUM_MAP.put(status.getCode(), status);
            CODE_MAP.put(status.getCode(), status.getMessage());
        }
    }


    public static boolean contains(Integer code) {
        return CODE_MAP.containsKey(code);
    }

    public static WeekDay getByCode(Integer code) {
        return ENUM_MAP.get(code);
    }

    public static Map<Integer, String> getCodeMap() {
        return Collections.unmodifiableMap(CODE_MAP);
    }

    public static Map<Integer, WeekDay> getEnumMap() {
        return Collections.unmodifiableMap(ENUM_MAP);
    }


    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }
}
